package uk.ac.manchester.cs.graph;

/**
 * 
 * @author Pavel Klinov
 *
 * pklinov@cs.man.ac.uk, pklinov@clarkparsia.com
 * 
 * Feb 3, 2009
 */
public class EdgeImpl<V, E> implements Edge<V, E> {

	private E m_label = null;
	private V m_start = null;
	private V m_end = null;
	
	public EdgeImpl(V start, V end) {
		
		m_start = start;
		m_end = end;
	}	
	
	public EdgeImpl(E object, V start, V end) {
		
		this(start, end);
		m_label = object;
	}
	
	public V getEnd() {

		return m_end;
	}

	public E getLabel() {

		return m_label;
	}

	public V getStart() {

		return m_start;
	}

	@SuppressWarnings("unchecked")
	@Override
	public boolean equals(Object obj) {

		return obj instanceof Edge 
			&& m_start.equals( ((Edge<V,E>)obj).getStart())
			&& m_end.equals( ((Edge<V,E>)obj).getEnd());
	}

	@Override
	public int hashCode() {

		return m_start.hashCode() + m_end.hashCode();
	}

	@Override
	public String toString() {

		return "<"+ m_start + "," + m_end +">";
	}

	
}
